import { getAreaObj } from '@/utils/util'
const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{
			label: '题库名称',
			prop: 'code',
		},
		{
			label: '题库分类',
			custome:"tag",
			propName:"typeLabel",
			prop: 'type',
		},
		{
			label: '题库数量',
			prop: 'itemNum',
		},
		{
			label: '创建人',
			prop: 'createUserName',
		},
		{
			label: '创建时间',
			prop: 'createTime',
		},
		{
			label: '是否启用',
			prop: 'isOpen',
		},
		{
			label: '操作',
			prop: 'menu',
			width: 400,
			fixed: 'right'
		},
	],
}

export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '题库名称',
			prop: 'code',
			type: 'input',
			span: 24,
			rules: [
				{
					required: true,
					message: '请输入题库名称',
					trigger: 'blur'
				}
			]
		},
		{
			label: '题库分类',
			prop: 'type',
			propName: 'typeLabel',
			type: 'remoteSelect',
			code:'OST_QUESTION_BANK_TYPE',
			api:'getDictItemList',
			span: 24,
			rules: [
				{
					required: true,
					message: '请选择题库分类',
					trigger: 'change'
				}
			]
		}
	],
}
const searchConfig = {
	inline: true,
// 	showBtn: true,
// 	labelPosition: 'left',
	column: [
		{
			label: '题库名称',
			prop: 'code',
			type: 'input',
			span: 8,
		},
		{
			label: '创建人',
			prop: 'createUserName',
			type: 'input',
			span: 8,
		},
		
		{
			label: '题库分类',
			prop: 'type',
			propName: 'typeLabel',
			span: 8,
			type: 'remoteSelect',
			code:'OST_QUESTION_BANK_TYPE',
			api:'getDictItemList',
		},
		{
			label: '是否启用',
			prop: 'isOpen',
			type: 'select',
			span: 8,
			dicData: [
				{label: '关闭',value: '0'},
				{label: '启用',value: '1'}
			]
		},
		{
			label: '创建时间',
			prop: 'createTimeBetween',
			type: 'datetimerange',
			format:'YYYY年MM月DD HH:mm:ss',
			valueFormat:'YYYY-MM-DD HH:mm:ss',
			span: 12,
		},
	],
}
// const detailConfig = {
// 	inline: false,
// 	labelPosition: 'left',
// 	labelWidth: '200px',
// 	showBtn: false,
// 	column: [
// 		{
// 			label: '名称',
// 			prop: 'projectName',
// 			span: 24,
// 		},
// 		{
// 			label: '选择申请补贴类型',
// 			prop: 'subsidyType',
// 			propName: 'subsidyTypeLabel',
// 			type: 'remoteSelect',
// 			api: 'getDictItemList',
// 			code: 'SUBSIDY_TYPE',
// 			filterKey: 'value',
// 			multiple: false,
// 			span: 24,
// 		},
// 		{
// 			label: '项目日期范围',
// 			prop: 'startToEnd',
// 			type: 'daterange',
// 			format: 'YYYY年MM月DD日',
// 			valueFormat: 'YYYY-MM-DD',
// 			span: 24,
// 		},
// 		{
// 			label: '状态',
// 			prop: 'projectEnable',
// 			type: 'radio',
// 			dicData: [
// 				{ label: '开启', value: 1 },
// 				{ label: '关闭', value: 0 },
// 			],
// 			span: 24,
// 		},
// 		{
// 			label: '选择申请配置信息',
// 			prop: 'subsidyApplyConfigId',
// 			type: 'remoteSelect',
// 			api: 'view_ofsSubsidyApplyConfig_list',
// 			filterKey: 'id',
// 			filterLabel: 'applyConfigName',
// 			multiple: false,
// 			span: 24,
// 		},
// 		{
// 			label: '是否开启自动申请',
// 			prop: 'autoApplyFlag',
// 			type: 'radio',
// 			dicData: [
// 				{ label: '开启', value: 1 },
// 				{ label: '关闭', value: 0 },
// 			],
// 			span: 24,
// 		},
// 		{
// 			label: '自动申请时限',
// 			prop: 'autoLimitDay',
// 			value: 0,
// 			display: false,
// 			type: 'input',
// 			span: 24,
// 		},
// 		{
// 			label: '选择审批配置信息',
// 			prop: 'approvalConfigId',
// 			type: 'remoteSelect',
// 			api: 'view_workflow_list',
// 			filterKey: 'id',
// 			filterLabel: 'workflowName',
// 			multiple: false,
// 			span: 24,
// 		},
// 	],
// }
export const baseConfig: any = {
	pageName: '题库管理',
	addLabel: '新建题库',
	dictcodes: ['OST_QUESTION_BANK_TYPE'],
	rowKey: 'id',
	tipLabel: 'code',
	api: {
		index: 'view_bscQuestionBank_page',
		add: 'view_bscQuestionBank_add',
		// export: 'view_ofsSubsidyApply_approval_exportApply'
		edit: 'view_bscQuestionBank_edit',
		delete: 'view_bscQuestionBank_del',
	},
	auth: {
		index: 'view_bscQuestionBank_page',
		add: 'view_bscQuestionBank_add',
		// mulitSet: 'view_ofsSubsidyApply_approval_exportApply'
		edit: 'view_bscQuestionBank_edit',
		delete: 'view_bscQuestionBank_del',
	},

	menuBtn: [
		{
			icon: '',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: 'view_bscQuestionBank_edit',
			text: true,
			show: true,
		},
		{
			icon: '',
			label: '题库管理',
			type: 'primary',
			operate: 'question',
			auth: 'view_workflowApprovalLogic_revocation',
			text: true,
			show: true,
		},
		// {
		// 	icon: '',
		// 	label: '停用',
		// 	type: 'primary',
		// 	operate: 'cancel',
		// 	auth: 'view_bscQuestionBank_del',
		// 	text: true,
		// 	show: true,
		// },
		{
			icon: '',
			label: '删除',
			type: 'primary',
			operate: 'delete',
			auth: 'view_bscQuestionBank_del',
			text: true,
			show: true,
		}
	],
	// dialogConfig: {
	// 	width: '65%',
	// },
	saveFormate: async (form) => {
		form.belongApp = form.type
		return new Promise((resolve, reject) => {
			resolve(form)
		})
	},
	beforeOnLoadFormate: async (query) => {
		return new Promise((resolve, reject) => {
			if(query.createTimeBetween){
				query.createTimeBetween = query.createTimeBetween.join(',')
			}else{
				query.createTimeBetween = undefined
			}
			const crAreasObj: any = getAreaObj(query.authAreas, '')
			resolve({
				...query,
				...crAreasObj,
				authAreas: undefined,
			})
		})
	},
	searchConfig,
	tableConfig,
	formConfig,
	// detailConfig,
}
